package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.exchangerecord.ExchangeRecordBO;
import com.micro.modual.model.dto.exchangerecord.ExchangeRecordDetailDTO;
import com.micro.modual.model.dto.exchangerecord.ExchangeRecordListDTO;
import com.micro.modual.service.ExchangeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>兑换记录表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "兑换管理",tags = "兑换管理")
@RestController
@RequestMapping(value = "exchangeRecord")
public class ExchangeRecordController {

    @Autowired
    private ExchangeRecordService exchangeRecordService;

    /**
     * <h2>查找兑换记录表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<ExchangeRecordListDTO> {@link ExchangeRecordListDTO}s  兑换记录表 列表返回对象
     */
    @ApiOperation(value = "查询兑换记录表列表" ,notes = "查询兑换记录表列表")
    @GetMapping(value = "/findExchangeRecordList")
    public RespJsonPageData<ExchangeRecordListDTO> findExchangeRecordList(@RequestParam  Map<String,Object> params){
        return exchangeRecordService.findList(params,ExchangeRecordListDTO.class);
    }

    /**
     * <h2>根据主键编号查看兑换记录表详情</h2>
     * @param id  兑换记录表 主键编号
     * @return {@link ExchangeRecordDetailDTO}  兑换记录表 详情
     */
    @ApiOperation(value = "查询兑换记录表详情",notes = "根据主键编号，查询兑换记录表详情")
    @GetMapping(value = "/findExchangeRecordDetail/{id}")
    public RespJsonData<ExchangeRecordDetailDTO> findExchangeRecordDetail(@PathVariable("id") Long id){
        return exchangeRecordService.findDetail(id,ExchangeRecordDetailDTO.class);
    }

    /**
     * <h2>新增兑换记录表详情</h2>
     * @param exchangeRecordBO {@link ExchangeRecordBO} 兑换记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增兑换记录表",notes = "新增兑换记录表")
    @PostMapping(value = "/addExchangeRecord")
    public RespJson addExchangeRecord(@RequestBody ExchangeRecordBO exchangeRecordBO){
        return exchangeRecordService.addExchangeRecord(exchangeRecordBO);
    }

    /**
     * <h2>修改兑换记录表详情</h2>
     * @param exchangeRecordBO  {@link ExchangeRecordBO} 兑换记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改兑换记录表",notes = "修改兑换记录表")
    @PostMapping(value = "/editExchangeRecord")
    public RespJson editExchangeRecord(@RequestBody ExchangeRecordBO exchangeRecordBO){
        return exchangeRecordService.editExchangeRecord(exchangeRecordBO);
    }

    /**
     * <h2>根据主键编号删除兑换记录表信息</h2>
     * @param id  兑换记录表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除兑换记录表",notes = "根据地址ID，删除兑换记录表")
    @PostMapping(value = "/deleteExchangeRecord/{id}")
    public RespJson deleteExchangeRecord(@PathVariable("id") Long id){
        return exchangeRecordService.deleteExchangeRecord(id);
    }
}

